#!/usr/bin/perl

use Cache::Memcached;

my $server = '127.0.0.1:11211';
my $memd = new Cache::Memcached { 'servers' => [ $server ] };

$memd->set("hoge".time,"test-data");
my $s     = $memd->stats();
my $count = $s->{total}->{curr_items};
my $items = $memd->stats("items");

my @items = split("\r\n|\n",$items->{hosts}->{$server}->{items});

for my $i (@items){
    if( $i =~ /STAT\ items:(\d+):number\ (\d+)/){
      my $cmd = "cachedump $1 $2";
      my $dump = $memd->stats($cmd);
      my %key = map{$_,s/ITEM\ (\S+)\ \[.+/$1/ig} split("\r\n|\n",$dump->{hosts}->{$server}->{$cmd});
      for(sort keys %key){print "$_\n"};      
    }
}

__END__


